home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9202 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  52 lines

  1. Path: library.erc.clarkson.edu!rpi!not-for-mail
  2. From: Tony Cook <tony@online.tmx.com.au>
  3. Newsgroups: comp.lang.c++,comp.lang.c++.moderated
  4. Subject: Re: Argc & Argv
  5. Date: 28 Feb 1996 22:33:40 -0000
  6. Organization: Home
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: Dietmar.Kuehl@uni-konstanz.de
  9. Message-ID: <4h2l84$ced@netlab.cs.rpi.edu>
  10. References: <4gta9f$df5@netlab.cs.rpi.edu>
  11. NNTP-Posting-Host: netlab.cs.rpi.edu
  12. X-Original-Date: Thu, 29 Feb 1996 09:26:16 +1100
  13.  
  14. Rick Richert (richert@butch.lmsc.lockheed.com) wrote:
  15. : >>  I tried posting this last week and am not sure if it was posted or
  16. : >>  not.  Soooo, I'm trying again.
  17.  
  18. : I have some global objects defined outside the main routine and I would
  19. : like to pass the argc and argv values to their constructors.  For example,
  20. :  
  21. :  
  22. : SomeClass obj( argc, argv);
  23. :  
  24. : int main( int argc, char **argv) {
  25. :  
  26. :    blah, blah, blah
  27. :  
  28. : }
  29. :  
  30. : Unfortunately, the compiler tells me that argc and argv are not defined
  31. : or else not available for obj.
  32. :  
  33. : Currently, I get around this problem by creating the global obj and then
  34. : inside of main, I initialize obj via a method that takes argc and argv.  
  35.  
  36. This is the most portable method.
  37.  
  38. : I would prefer to pass the arg vars to the constructor.  Does anyone know
  39. : how I can pass the arg vars without being inside of main?
  40.  
  41. Some DOS/Windows compiler supply the argc and argv values global
  42. variables (Borland and Watcom), but it's hardly portable.
  43.  
  44. -- 
  45.         Tony Cook - tony@online.tmx.com.au
  46.                     100237.3425@compuserve.com
  47.  
  48.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  49.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  50.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  51.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  52.